package com.nbicc.common.utils;

import org.springframework.validation.BindingResult;

/**
 * @Author: lilingyan
 */
public class BindingResultUtils {

    /***
     * 如果绑定时出错，则把错误信息拼接成字符串返回
     * @param bindingResult
     * @return
     */
    public static String getMessages(BindingResult bindingResult){
        StringBuffer sb = new StringBuffer();
        bindingResult.getAllErrors().stream().forEach(error->{
            sb.append(error.getDefaultMessage());
        });
        return sb.toString();
    }

}
